/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package muddb.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;


/**
 *
 * @author keith
 */
@Entity
@Table( name = "mud_item_class" )
@NamedQueries( { @NamedQuery( name = "MudItemClass.findByItemClassId", query =
                                                                       "SELECT m FROM MudItemClass m WHERE m.itemClassId = :itemClassId" ),
                 @NamedQuery( name = "MudItemClass.findByItemDesc", query =
                                                                    "SELECT m FROM MudItemClass m WHERE m.itemDesc = :itemDesc" ) } )
public class MudItemClass implements Serializable {
  private static final long serialVersionUID = 1L;
  @Id
  @GeneratedValue(strategy=GenerationType.SEQUENCE)
  @Column( name = "item_class_id", nullable = false )
  private Integer itemClassId;
  @Column( name = "item_desc", length=40, nullable = false )
  private String itemDesc;
  @OneToMany( cascade = CascadeType.ALL, mappedBy = "mudItemClass" )
  private Collection<MudItemClassAttr> mudItemClassAttrCollection;
  @OneToMany( cascade = CascadeType.ALL, mappedBy = "mudItemClass" )
  private Collection<MudItem> mudItemCollection;


  public MudItemClass() {
  }


  public MudItemClass( Integer itemClassId ) {
    this.itemClassId = itemClassId;
  }


  public MudItemClass( Integer itemClassId, String itemDesc ) {
    this.itemClassId = itemClassId;
    this.itemDesc = itemDesc;
  }


  public Integer getItemClassId() {
    return itemClassId;
  }


  public void setItemClassId( Integer itemClassId ) {
    this.itemClassId = itemClassId;
  }


  public String getItemDesc() {
    return itemDesc;
  }


  public void setItemDesc( String itemDesc ) {
    this.itemDesc = itemDesc;
  }


  public Collection<MudItemClassAttr> getMudItemClassAttrCollection() {
    return mudItemClassAttrCollection;
  }


  public void setMudItemClassAttrCollection( Collection<MudItemClassAttr> mudItemClassAttrCollection ) {
    this.mudItemClassAttrCollection = mudItemClassAttrCollection;
  }


  public Collection<MudItem> getMudItemCollection() {
    return mudItemCollection;
  }


  public void setMudItemCollection( Collection<MudItem> mudItemCollection ) {
    this.mudItemCollection = mudItemCollection;
  }


  @Override
  public int hashCode() {
    int hash = 0;
    hash += ( itemClassId != null ? itemClassId.hashCode() : 0 );
    return hash;
  }


  @Override
  public boolean equals( Object object ) {
    // TODO: Warning - this method won't work in the case the id fields are not set
    if ( !( object instanceof MudItemClass ) ) {
      return false;
    }
    MudItemClass other = (MudItemClass) object;
    if ( ( this.itemClassId == null && other.itemClassId != null ) || ( this.itemClassId != null && !this.itemClassId.equals( other.itemClassId ) ) ) {
      return false;
    }
    return true;
  }


  @Override
  public String toString() {
    return "muddb.entities.MudItemClass[itemClassId=" + itemClassId + "]";
  }

}
